#ifndef __SEMAPHORE_H__
#define __SEMAPHORE_H__

#include "plat/nonecopyable.h"

class Semaphore : public NoneCopyable
{
public:
    explicit Semaphore(int initialCount = 1, int maximumCount = 1);
    virtual ~Semaphore();

public:
    int GetCurrentCount();

    bool TryAcquire();
    //-1为永远等待
    bool Acquire(int timeout = -1);
    void Release();
    void Clear();

    Semaphore &Zero();

private:
    void *m_semHandle = nullptr;
};

#endif // __SEMAPHORE_H__
